/*
 * @(#)MaintDmsVersionForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.dms.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import com.dcivision.dms.DmsOperationConstant;
import com.dcivision.dms.bean.DmsVersion;
import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;

/**
  MaintDmsVersionForm.java

  This class is the for web form purpose.

  @author      Zoe Shum
  @company     DCIVision Limited
  @creation date   17/08/2003
  @version     $Revision: 1.13 $
*/

public class MaintDmsVersionForm extends MaintDmsDocumentForm {

  public static final String REVISION = "$Revision: 1.13 $";

  private String documentID = null;
  private String versionNumber = null;
  private String versionLabel = null;
  private String parentID = null;
  private String contentID = null;
  private String bkArchiveID = null;
  private String referenceNo = null;
  private String description = null;
  private String itemSize = null;
  private String itemStatus = null;
  private String restoreStatus = null;

  /** indicate the corresponding document rootID and parentID*/
  private String rootID = null;
  private String docparent = null;

  /** indicate the uploaded file */
  private FormFile uploadFile =null;
  private String checkinType = DmsOperationConstant.CREATE_NEW_CHECKIN;

  /** indicate the flag for auto label or manual*/
  private String labelFlag = null;
  private String curFunctionCode = null;

  private String closeFlag = null;

  /** indicate the directing page*/
  private String directPage = null;
  
  /** used for return button to find return navigation */
  private String directURL=null;

  /** this property is just for odma */
  private FormFile formFieldXmlFile =null;  
  private String checkinFileName = null;
  
  public MaintDmsVersionForm() {
    super();
  }

  public String getDocumentID() {
    return(this.documentID);
  }

  public void setDocumentID(String documentID) {
    this.documentID = documentID;
  }

  public String getVersionNumber() {
    return(this.versionNumber);
  }

  public void setVersionNumber(String versionNumber) {
    this.versionNumber = versionNumber;
  }

  public String getVersionLabel() {
    return(this.versionLabel);
  }

  public void setVersionLabel(String versionLabel) {
    this.versionLabel = versionLabel;
  }

  public String getParentID() {
    return(this.parentID);
  }

  public void setParentID(String parentID) {
    this.parentID = parentID;
  }

  public String getContentID() {
    return(this.contentID);
  }

  public void setContentID(String contentID) {
    this.contentID = contentID;
  }

  public String getBkArchiveID() {
    return(this.bkArchiveID);
  }

  public void setBkArchiveID(String bkArchiveID) {
    this.bkArchiveID = bkArchiveID;
  }

  public String getReferenceNo() {
    return(this.referenceNo);
  }

  public void setReferenceNo(String referenceNo) {
    this.referenceNo = referenceNo;
  }

  public String getDescription() {
    return(this.description);
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getItemSize() {
    return(this.itemSize);
  }

  public void setItemSize(String itemSize) {
    this.itemSize = itemSize;
  }

  public String getItemStatus() {
    return(this.itemStatus);
  }

  public void setItemStatus(String itemStatus) {
    this.itemStatus = itemStatus;
  }

  public String getRestoreStatus() {
    return(this.restoreStatus);
  }

  public void setRestoreStatus(String restoreStatus) {
    this.restoreStatus = restoreStatus;
  }

  public void setUploadFile(FormFile uploadFile) {
     this.uploadFile = uploadFile;
  }

  public FormFile getUploadFile() {
    return uploadFile;
  }

  public void setCheckinType(String checkinType) {
    this.checkinType = checkinType;
  }

  public String getCheckinType() {
    return checkinType;
  }

  public void setDocparent(String docparent) {
    this.docparent = docparent;
  }

  public String getDocparent() {
    return docparent;
  }

  public void setRootID(String rootID) {
    this.rootID = rootID;
  }

  public String getRootID() {
    return rootID;
  }

  /**
   * Set auto label flag for auto assignment or not
   * @param labelFlag
   */
  public void setLabelFlag(String labelFlag) {
    this.labelFlag = labelFlag;
  }

  /**
   * Get auto label flag for auto assignment or not
   * @return String "on" if auto assigement
   */
  public String getLabelFlag() {
    return labelFlag;
  }

  public void setCurFunctionCode(String curFunctionCode) {
    this.curFunctionCode = curFunctionCode;
  }

  public String getCurFunctionCode() {
    return curFunctionCode;
  }

  public void setCloseFlag(String closeFlag) {
    this.closeFlag = closeFlag;
  }

  public String getCloseFlag() {
    return closeFlag;
  }

  public void setDirectPage(String directPage) {
    this.directPage = directPage;
  }

  public String getDirectPage() {
    return directPage;
  }
  
  public void setDirectURL(String directURL){
    this.directURL=directURL; 
  }
  
  public String getDirectURL(){
    return this.directURL; 
  }

  public boolean getBooleanLabelFlag() {
    if (labelFlag == null || !"on".equals(labelFlag)) {
      return false;
    }
    else {
      return true;
    }
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setDocumentID(null);
    this.setVersionNumber(null);
    this.setVersionLabel(null);
    this.setParentID(null);
    this.setContentID(null);
    this.setBkArchiveID(null);
    this.setReferenceNo(null);
    this.setDescription(null);
    this.setItemSize(null);
    this.setItemStatus(null);
    this.setRestoreStatus(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
    this.setUploadFile(null);
    this.setRootID(null);
    this.setDocparent(null);
    this.setCurFunctionCode(null);
    this.setDirectPage(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    DmsVersion tmpDmsVersion = new DmsVersion();
    tmpDmsVersion.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpDmsVersion.setDocumentID(TextUtility.parseIntegerObj(this.getDocumentID()));
    tmpDmsVersion.setVersionNumber(this.getVersionNumber());
    tmpDmsVersion.setVersionLabel(this.getVersionLabel());
    tmpDmsVersion.setParentID(TextUtility.parseIntegerObj(this.getParentID()));
    tmpDmsVersion.setContentID(TextUtility.parseIntegerObj(this.getContentID()));
    tmpDmsVersion.setBkArchiveID(TextUtility.parseIntegerObj(this.getBkArchiveID()));
    tmpDmsVersion.setReferenceNo(this.getReferenceNo());
    tmpDmsVersion.setDescription(this.getDescription());
    tmpDmsVersion.setItemSize(TextUtility.parseIntegerObj(this.getItemSize()));
    tmpDmsVersion.setItemStatus(this.getItemStatus());
    tmpDmsVersion.setRestoreStatus(this.getRestoreStatus());
    tmpDmsVersion.setRecordStatus(this.getRecordStatus());
    tmpDmsVersion.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpDmsVersion.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpDmsVersion.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpDmsVersion.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpDmsVersion.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpDmsVersion;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    DmsVersion tmpDmsVersion = (DmsVersion)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpDmsVersion.getID()));
    this.setDocumentID(TextUtility.formatIntegerObj(tmpDmsVersion.getDocumentID()));
    this.setVersionNumber(tmpDmsVersion.getVersionNumber());
    this.setVersionLabel(tmpDmsVersion.getVersionLabel());
    this.setParentID(TextUtility.formatIntegerObj(tmpDmsVersion.getParentID()));
    this.setContentID(TextUtility.formatIntegerObj(tmpDmsVersion.getContentID()));
    this.setBkArchiveID(TextUtility.formatIntegerObj(tmpDmsVersion.getBkArchiveID()));
    this.setReferenceNo(tmpDmsVersion.getReferenceNo());
    this.setDescription(tmpDmsVersion.getDescription());
    this.setItemSize(TextUtility.formatIntegerObj(tmpDmsVersion.getItemSize()));
    this.setItemStatus(tmpDmsVersion.getItemStatus());
    this.setRestoreStatus(tmpDmsVersion.getRestoreStatus());
    this.setRecordStatus(tmpDmsVersion.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpDmsVersion.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpDmsVersion.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpDmsVersion.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpDmsVersion.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpDmsVersion.getUpdateDate()));
  }

  public void setFormFieldXmlFile(FormFile formFieldXmlFile) {
     this.formFieldXmlFile = formFieldXmlFile;
  }

  public FormFile getFormFieldXmlFile() {
    return formFieldXmlFile;
  }

  public void setCheckinFileName(String checkinFileName){
    this.checkinFileName=checkinFileName; 
  }
  
  public String getCheckinFileName(){
    return this.checkinFileName;     
  }

  
}
